package com.vlong.town.controller.server.tourist;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageHelper;
import com.vlong.town.controller.base.BaseController;
import com.vlong.town.entity.tourist.TouristInfo;
import com.vlong.town.service.tourist.TouristInfoService;
/**
 * 旅游景点信息Rest接口Controller
 * @author Assassin
 */
@RequestMapping("/rest/tourist")
@RestController
public class TouristInfoRestController extends BaseController{

    @Autowired
    private TouristInfoService touristInfoService;// 旅游景点信息业务实现类
    
    
    /**
     * 查询旅游景点信息
     * @param pageNo 当前页码
     * @param pageSize 每页显示记录数
     * @return List<TouristInfo>
     */
    @GetMapping("/list/{pageNo}/{pageSize}")
    public List<TouristInfo> list(
            @PathVariable(required=true, value="pageNo") Integer pageNo,
            @PathVariable(required=true, value="pageSize") Integer pageSize) {
        PageHelper.startPage(getPageNo(pageNo), getPageSize(pageSize));
        PageHelper.orderBy("update_time DESC");
        List<TouristInfo> touristInfoList = this.touristInfoService.queryList(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
        return touristInfoList;
    }
    
    
    /**
     * 小程序
     * 查询旅游景点信息
     * @return List<TouristInfo>
     */
    @GetMapping("/listXcx")
    public List<TouristInfo> listXcx() {
        List<TouristInfo> touristInfoList = this.touristInfoService.queryList(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
        for (TouristInfo touristInfo : touristInfoList) {
        	Long createTime = touristInfo.getCreateTime();
        	SimpleDateFormat  sdf=new  SimpleDateFormat("yyyy-MM-dd");
        	Date date = new  Date(createTime);
        	String format = sdf.format(date);
        	touristInfo.setCreateDate(format);
		}
        return touristInfoList;
    }
    
    /**
     * 查询旅游景点详情
     * @param id 旅游景点id
     * @return TouristInfo
     */
    @GetMapping("/detail/{id}")
    public TouristInfo detail(@PathVariable(value="id") Long id) {
    	return touristInfoService.queryById(id);
    }
}
